package bairui.international.weixin.portal.miniapp.controller.college.college;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.querydsl.QSort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.model.uml.model.status.State_UpDown;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_College;
import bairui.international.service.Service_College;
import bairui.international.service.Service_CollegeImage;

/**
 *
 * 列表
 *
 * @generated
 * 
 * @see STest_C_College_Page_Get 测试
 *
 */
@Controller
public class C_College_Page_Get
 extends SC_College_Page_Get 
{
	
	@Autowired private Service_College service_College;
	@Autowired private Service_CollegeImage service_CollegeImage;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request,
		@RequestParam String skey,
		@RequestParam Long categoryId,
		@RequestParam Integer startPage
	) throws Exception {
		Page<TB_College> page = service_College.page(it->
			it.state.eq(State_UpDown.Uped).and(it.collegeCategory.id.eq(categoryId)),
			PageRequest.of(startPage, 5), 
			it->new QSort(it.orderValue.desc(), it.date.desc())
		);
		return page.map(it->new Output(it, service_CollegeImage));
	}
	

}
